<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<!DOCTYPE html>
<html lang="zh-CN">
    <head>
        <meta charset="UTF-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <%@ include file="/WEB-INF/views/include/head.jsp"%> 
        <link rel="stylesheet" href="${ctxStatic}/css/list.css">
            <script type="text/javascript">
                $(document).ready(function(){
                    $("#materialTypeCd,#materialUseType").select2();
                   });
               //重置
               function clean(){
                   $("input").val("");
                   $('#materialTypeCd,#materialUseType').val('');
                   $("#materialTypeCd,#materialUseType").select2(); 
                   $("#searchForm").submit();
               }
               
            </script> 
    </head>
    <body>
        <form  id="searchForm" action="${ctx}/material/mymaterial/list" method="post">
        <input id="pageNo" name="pageNo" type="hidden" value="${page.pageNo}"/>
        <input id="pageSize" name="pageSize" type="hidden" value="${page.pageSize}"/>
        <c:set value="<%=ResourcesUtil.getConfig(\"material_Category\")%>" var="materialCategory" />
        <c:set value="<%=ResourcesUtil.getConfig(\"material_UseType\")%>" var="useType" />
            <div class="listSearchBox clearfix">
                <div class="searchLeft clearfix">
                    <div class="searchSm clearfix">
                        <!-- 业务类别 -->
                        <p class="searchTxt"><spring:message code="myMaterial_businessType"/></p>
                        <div class="searchInp">
                            <select  style="width:110px" id="materialUseType" name="materialUseType">
                                <option value=""><spring:message code="myMaterial_pleaseChoosed"/></option>
                                <c:forEach items="${fns:getDictList(useType)}"   var="type">
                                    <option  <c:if test="${fn:split(material.materialUseType,'-')[1] eq type.itemValue}">selected="selected"</c:if> value="${type.itemCode}-${type.itemValue}" > 
                                        ${type.itemName}
                                    </option>
                                </c:forEach>
                            </select>
                        </div>
                    </div>
                    <div class="searchSm clearfix">
                        <!-- 物料类别 -->
                        <p class="searchTxt"><spring:message code="myMaterial_materialType"/></p>
                        <div class="searchInp">
                            <select  style="width:110px" id="materialTypeCd" name="materialTypeCd" >
                                <option value=""><spring:message code="myMaterial_pleaseChoosed"/></option>
                                <c:forEach items="${fns:getDictList(materialCategory)}"   var="category">
                                    <option  <c:if test="${fn:split(material.materialTypeCd,'-')[1] eq category.itemValue}">selected="selected"</c:if> value="${category.itemCode}-${category.itemValue}" > 
                                        ${category.itemName}
                                    </option>
                                </c:forEach>
                            </select>
                        </div>
                    </div>
                    <div class="searchSm clearfix">
                        <!-- 物料名称 -->
                        <p class="searchTxt"><spring:message code="myMaterial_name"/></p>
                        <div class="searchInp">
                            <input type="text"  id="materialNameCn"  name="materialNameCn"  value="${material.materialNameCn}" >
                        </div>
                    </div>
                    <div class="searchSm clearfix">
                        <!-- 物料颜色 -->
                        <p class="searchTxt"><spring:message code="myMaterial_color"/></p>
                        <div class="searchInp">
                            <input type="text"  id="materialColor"  name="materialColor"  value="${material.materialColor}" >
                        </div>
                    </div>
                    <div class="searchSm clearfix">
                        <!-- 物料成分 -->
                        <p class="searchTxt"><spring:message code="myMaterial_composition"/></p>
                        <div class="searchInp">
                            <input type="text"  id="materialComposition"  name="materialComposition"  value="${material.materialComposition}" >
                        </div>
                    </div>
                </div>
                <div class="searchRight">
                    <!-- 新建 -->
                    <shiro:hasPermission name="material:mymaterial:edit">
                        <button type="button" class="btn-cj" onclick="popup('935px','550px','${ctx}/material/mymaterial/form')"><spring:message code="myMaterial_create"/></button>
                    </shiro:hasPermission>
                    <!-- 重置 -->
                    <button type="button" class="btn-js" onclick="clean();"><spring:message code="myMaterial_reset"/></button>
                    <!-- 查询 -->
                    <button type="button" class="btn-js" onclick="return page();"><spring:message code="commom_check"/></button>
                </div>
            </div>
        </form>
        <div class="tableBox">
            <div class="tableBoxScroll tablePic">
                <div class="tabScroll">
                <table cellpadding="0">
                    <thead>
                        <tr>
                            <!-- 序号No. -->
                            <th><spring:message code="common_no"/></th>
                            <!-- 物料图片 -->
                            <th><spring:message code="myMaterial_pic"/></th>
                            <!-- 编码/物料名称 -->
                            <th><spring:message code="myMaterial_code_name"/></th>
                            <!-- 业务类别 -->
                            <th><spring:message code="myMaterial_businessType"/></th>
                            <!-- 物料类别 -->
                            <th><spring:message code="myMaterial_materialType"/></th>
                            <!-- 物料颜色 -->
                            <th><spring:message code="myMaterial_color"/></th>
                            <!-- 物料成分 -->
                            <th><spring:message code="myMaterial_composition"/></th>
                            <!-- 物料规格 -->
                            <th><spring:message code="myMaterial_spec"/></th>
                            <!-- 季节年份 -->
                            <th><spring:message code="myMaterial_seasonAndYear"/></th>
                            <!-- 描述 -->
                            <th><spring:message code="myMaterial_remarks"/></th>
                        </tr>
                    </thead>
                    <c:if test="${not empty page.list}" >
                        <tbody>
                            <c:forEach items="${page.list}" var="myMaterial" varStatus="status">
                                <tr>
                                    <td>
                                        <p>${(page.pageNo-1)*page.pageSize + status.index+1}</p>
                                    </td>
                                    <td>
                                        <c:if test="${not empty myMaterial.filePath}">
                                           <img src="${myMaterial.filePath}" class="tableImg">
                                           <img src="${myMaterial.filePath}" class="posImg">
                                        </c:if>
                                        <c:if test="${empty myMaterial.filePath}">
                                           <img src="${ctxStatic}/images/pic-none.jpg" class="tableImg">
                                        </c:if>
                                    </td>
                                    <td>
                                        <c:choose>
                                            <c:when test="${languageFlag=='cn'}">
                                        <p style="line-height: 18px;"  data-toggle="tooltip" title="${myMaterial.materialNameCn}" class="show" onclick="popup('800px','550px','${ctx}/material/mymaterial/show?id=${myMaterial.id}')">${myMaterial.materialCode}<br>${myMaterial.materialNameCn}</p>
                                            </c:when>
                                            <c:otherwise>
                                        <p style="line-height: 18px;"  data-toggle="tooltip" title="${myMaterial.materialNameEn}" class="show" onclick="popup('800px','550px','${ctx}/material/mymaterial/show?id=${myMaterial.id}')">${myMaterial.materialCode}<br>${myMaterial.materialNameEn}</p>
                                            </c:otherwise>
                                        </c:choose>
                                    </td>
                                    <td>
                                        <p data-toggle="tooltip" title="${fns:getDictName(myMaterial.materialUseType)}">${fns:getDictName(myMaterial.materialUseType)}</p>
                                    </td>
                                    <td>
                                        <p data-toggle="tooltip" title="${fns:getDictName(myMaterial.materialTypeCd)}">${fns:getDictName(myMaterial.materialTypeCd)}</p>
                                    </td>
                                    <td>
                                        <p data-toggle="tooltip" title="${myMaterial.materialColor}">${myMaterial.materialColor}</p>
                                    </td>
                                    <td>
                                        <p data-toggle="tooltip" title="${myMaterial.materialComposition}">${myMaterial.materialComposition}</p>
                                    </td>
                                    <td>
                                        <p data-toggle="tooltip" title="${myMaterial.materialSpec} ${fns:getDictName(myMaterial.materialUnitCd)}">${myMaterial.materialSpec} ${fns:getDictName(myMaterial.materialUnitCd)}</p>
                                    </td>
                                    <td>
                                        <p data-toggle="tooltip" title="${myMaterial.materialYear} ${fns:getDictName(myMaterial.materialSeason)}">${myMaterial.materialYear} ${fns:getDictName(myMaterial.materialSeason)}</p>
                                    </td>
                                    <td>
                                        <p data-toggle="tooltip" title="${myMaterial.remarks}">${myMaterial.remarks}</p>
                                    </td>
                                </tr>
                            </c:forEach>
                        </tbody>
                    </c:if>
                </table>
                <c:if test="${empty page.list}" >
                    <div class="tableNone">
                        <img src="${ctxStatic}/images/icon-03.png" height="20"> <spring:message code="There_is_no_data"/>
                    </div>
                </c:if>
           </div>
            </div>
            <%@ include file="/WEB-INF/views/include/page.jsp"%>
        </div>
        <script src="${ctxStatic}/layer/layerStyle.js"></script>
        <script>
            var listH = $(':root').css('height');
                $(window.parent.$("#mainFrame").css('height',listH));
                window.onload = function(){
                    var theadW = $('.tabScroll thead').width()
                    var theadTh = $('.tabScroll thead tr th').length
                    $('.tabScroll thead tr th').width(theadW/theadTh)
                    $('.tabScroll tbody tr:first-child td').each(function(){
                        var indexNum = $(this).index()
                        var tdWidth = $('.tabScroll tbody tr:first-child td').eq(indexNum).css('width')
                        $('.tabScroll thead tr th').eq(indexNum).width(tdWidth);
                    })

                }
        </script> 
    </body>
</html>